package com.wolf.etl.enumeration;

import com.wolf.exception.WolfException;

/**
 * Created by tommy's father on 2017/8/26.
 */
public enum INFO_TYPE {
    EXTRACT_FLAG("EXTRACT_FLAG"),
    WRITE_BACK_FLAG("WRITE_BACK_FLAG"),
    WRITE_BACK_FAIL_MSG("WRITE_BACK_FAIL_MSG"),
    WRITE_BACK_TIME("WRITE_BACK_TIME");
    private String infoType;

    public static boolean contains(String infoType) {
        String[] infoTypeArrs = new String[]{"EXTRACT_FLAG", "WRITE_BACK_FLAG", "WRITE_BACK_FAIL_MSG", "WRITE_BACK_TIME"};
        for (String info : infoTypeArrs) {
            if (info.equalsIgnoreCase(infoType)) {
                return true;
            }
        }
        return false;
    }

    INFO_TYPE(String infoType) {
        if (!contains(infoType)) {
            throw new WolfException(String.format("INFO_TYPE:The value of infoType[%s] is out of range.", infoType));
        }
        this.infoType = infoType;
    }

    public boolean isEquals(String infoType) {
        return this.infoType.equalsIgnoreCase(infoType);
    }
}
